<?php

use think\migration\Migrator;
use think\migration\db\Column;

class ReceiveLog extends Migrator
{
    /**
     * Change Method.
     *
     * Write your reversible migrations using this method.
     *
     * More information on writing migrations is available here:
     * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
     *
     * The following commands can be used in this method and Phinx will
     * automatically reverse them when rolling back:
     *
     *    createTable
     *    renameTable
     *    addColumn
     *    renameColumn
     *    addIndex
     *    addForeignKey
     *
     * Remember to call "create()" or "update()" and NOT "save()" when working
     * with the Table class.
     */
    public function change()
    {
        $table = $this->table('receive_log', ['engine' => 'InnoDB', 'comment' => '收款记录', 'signed' => false]);
        $table->addColumn('company_id', 'integer', ['limit' => 10, 'default' => 0, 'comment' => '公司id', 'signed' => false])
              ->addColumn('store_id', 'integer', ['limit' => 10, 'default' => 0, 'comment' => '门店id', 'signed' => false])
              ->addColumn('payee_type', 'integer', ['limit' => 10, 'default' => 0, 'comment' => '收款人类型：1业务员，2司机', 'signed' => false])
              ->addColumn('payee_id', 'integer', ['limit' => 10, 'default' => 0, 'comment' => '收款人id', 'signed' => false])
              ->addColumn('company_order_id', 'string', ['limit' => 255, 'default' => '', 'comment' => '子订单id组，逗号隔开', 'collation' => 'utf8mb4_general_ci'])
              ->addColumn('company_order_pid', 'string', ['limit' => 255, 'default' => '', 'comment' => '主订单id组，逗号隔开', 'collation' => 'utf8mb4_general_ci'])
              ->addColumn('pay_type', 'integer', ['limit' => 10, 'default' => 0, 'comment' => '收款方式：1现金（支付宝微信等）2公司账户', 'signed' => false])
              ->addColumn('reason', 'integer', ['limit' => 10, 'default' => 0, 'comment' => '收款原因：1订单收款 2欠款收款 3存储余额（预存款）4账期收款', 'signed' => false])
              ->addColumn('money', 'decimal', ['default' => 0.00, 'comment' => '金额', 'signed' => false])
              ->addColumn('image', 'string', ['limit' => 255, 'default' => '', 'comment' => '收款凭证', 'collation' => 'utf8mb4_general_ci'])
              ->addColumn('remark', 'string', ['limit' => 255, 'default' => '', 'comment' => '备注', 'collation' => 'utf8mb4_general_ci'])
              ->addColumn('create_time', 'integer', ['limit' => 10, 'default' => null, 'comment' => '创建时间'])
              ->addColumn('update_time', 'integer', ['limit' => 10, 'default' => null, 'comment' => '更新时间'])
              ->addColumn('delete_time', 'integer', ['limit' => 10, 'default' => null, 'comment' => '删除时间'])
              ->addIndex('company_id', ['name' => 'idx_company_id'])
              ->addIndex('store_id', ['name' => 'idx_store_id'])
              ->addIndex('payee_type', ['name' => 'idx_payee_type'])
              ->addIndex('payee_id', ['name' => 'idx_payee_id'])
              ->addIndex('company_order_id', ['name' => 'idx_company_order_id'])
              ->addIndex('company_order_pid', ['name' => 'idx_company_order_pid'])
              ->addIndex('pay_type', ['name' => 'idx_pay_type'])
              ->addIndex('reason', ['name' => 'idx_reason'])
              ->create();
    }
}
